import { createSSRApp } from "vue";
import App from "./App.vue";
import uViewPlus , {setConfig}from 'uview-plus';
import 'virtual:uno.css'
import PageTemplate from './components/PageTemplate.vue'
import { ZSwiper, ZSwiperItem } from '@zebra-ui/swiper'
import MarkTips from './components/MarkTips.vue'
import HireButton from './components/HireButton.vue'
import PriceBox from './components/PriceBox.vue'
import DiscountButton from "./components/DiscountButton.vue";


export function createApp() {
  const app = createSSRApp(App);

  // 动态创建script标签并添加到head中
  const loadScript = (url: string) => {
    const script = document.createElement('script')
    script.type = 'text/javascript'
    script.src = url
    document.head.appendChild(script)
  }
  // 引入远程JS文件
  loadScript('https://appx/web-view.min.js')

  app.component('PageTemplate', PageTemplate)
  app.component('ZSwiper', ZSwiper) 
  app.component('ZSwiperItem', ZSwiperItem)
  app.component('MarkTips', MarkTips)
  app.component('HireButton', HireButton)
  app.component('PriceBox', PriceBox)
  app.component('DiscountButton', DiscountButton)

  app.use(uViewPlus)
  setConfig({
    // 修改$u.config对象的属性
    config: {
      // 修改默认单位为rpx，相当于执行 uni.$u.config.unit = 'rpx'
      unit: 'px'
    },
    // 修改$u.props对象的属性
    props: {
      // 修改radio组件的size参数的默认值，相当于执行 uni.$u.props.radio.size = 30
      radio: {    
        // size: 20 
      }
      // 其他组件属性配置
      // ......
    }
  })
  return {
    app,
  };
}
